package cn.shangtour.diary.diaryservice;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.shangtour.common.pojo.Diary;
import cn.shangtour.common.vo.DiaryUIResult;
import cn.shangtour.diary.diarymapper.diaryMapper;

@Service
public class DiaryService {
	@Autowired
	private diaryMapper diaryMapper;
	public void diarySave(Diary diary){
		diary.setDiaryId(UUID.randomUUID().toString());
		diaryMapper.diarySave(diary);
	}
	public DiaryUIResult diaryPageQuery(Integer page, Integer rows) {
		DiaryUIResult diaresult=new DiaryUIResult();
		Integer diatotal=diaryMapper.queryTotal();
		Integer start=(page-1)*rows;
		List<Diary>dList=diaryMapper.queryByPage(start,rows);
		diaresult.setTotal(diatotal);
		diaresult.setRows(dList);
        return diaresult;		
	}
}
